import axios from "axios";
import qs from 'qs'
export function request(config) {
  return new Promise((resolve, reject) => {
    const instance = axios.create({
      baseURL: process.env.NODE_ENV === "production" ? "http://121.36.226.94:8081" : "http://121.36.226.94:8081",
      // baseURL: process.env.NODE_ENV === "production" ? "https://localhost:44372" : "https://localhost:44372",
      headers: {
        'Content-Type': 'application/json'
      },
      withCredentials: false,
      // transformRequest:[(data)=> {
      //   if(config.method === 'post'){
      //     config.data = qs.stringify(data)
      //   }
      //   return data;
      // }],
      timeout: 10000,
      
    });
    instance(config)
      .then((res) => {
        resolve(res);
      })
      .catch((err) => {
        reject(err);
      });
  });
}
